using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using au.Swindles.CustomerEnquiryService.ObjectLayer;
using au.Swindles.CustomerEnquiryService.BLLayer;

namespace au.Swindles.CustomerEnquiryService
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://au.bank.Swindles/CustomerEnquiryService")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class Service : System.Web.Services.WebService
    {
        
        [WebMethod]
        public bool validateCustomer(string pCustomerNumber, string pCustomerName)
        {
            bool isValid = false;
            try
            {
                Customer customer = BLCustomer.getCustomer(pCustomerNumber, pCustomerName);
                if(customer != null)
                {
                    isValid = true;
                }
            }
            catch (Exception ex)
            {
            }
            return isValid;
        }

        [WebMethod]
        public int getCreditRating(string pCustomerNumber)
        {
            int creditRating = 0;
            try
            {
                Customer customer = BLCustomer.getCustomer(pCustomerNumber);
                if (customer != null)
                {
                    creditRating = customer.CreditRating;
                }
            }
            catch (Exception ex)
            {
            }
            return creditRating;

        }

        [WebMethod]
        public Customer getCustomerDetails(string pCustomerNumber)
        {
            Customer customer = null;
            try
            {
                customer = BLCustomer.getCustomer(pCustomerNumber);
            }
            catch (Exception ex)
            {
            }
            return customer;
        }

        [WebMethod]
        public Customer getCustomerDetailsByID(int pCustomerID)
        {
            Customer customer = null;
            try
            {
                customer = BLCustomer.getCustomer(pCustomerID);
            }
            catch (Exception ex)
            {
            }
            return customer;
        }

        [WebMethod]
        public bool updateCustomerDetails(Customer pCustomer)
        {
            try
            {
                return BLCustomer.updateCustomer(pCustomer);
            }
            catch (Exception ex)
            {
                return false;
            }
        }

    }
}
